package com.clementheliou.cheliou.dal.model.photo.dto;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.joda.time.LocalDateTime;

import com.clementheliou.cheliou.dal.model.photo.Photo;
import com.clementheliou.cheliou.dal.model.photo.util.PhotoUtils;

/**
 * Data transfer object related to the {@link Photo} domain one. It should be used when you only
 * need some fields of the entity for a read-only purpose. This kind of class must not have any
 * behavior.
 * 
 * @author Clément HELIOU (clement.heliou@gmail.com)
 * @see {@link Photo}.
 * @since 1.0
 */
public class PhotoDTO implements Serializable {

	/**
	 * UID for serialization.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private static final long serialVersionUID = -4314128745449798308L;

	/**
	 * The photo's identifier.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private Integer entityId;

	/**
	 * The photo's addition date.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private LocalDateTime additionDate;

	/**
	 * The photo's shooting date.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private LocalDateTime shootingDate;

	/**
	 * The path to the gallery version of the photo.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private String galleryPath;

	/**
	 * The key of the photo's title.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @since 1.0
	 */
	private String titleKey;

	/**
	 * Builder from the given parameters.
	 * 
	 * @author Clément HELIOU (clement.heliou@gmail.com)
	 * @param additionDate the addition date of the photo.
	 * @param entityId the identifier of the photo into the DB.
	 * @param code the code of the photo.
	 * @param shootingDate the shooting date of the photo.
	 * @param titleKey the key of the photo's title.
	 * @since 1.0
	 */
	public PhotoDTO(final LocalDateTime additionDate, final Integer entityId, final String code, final LocalDateTime shootingDate, final String titleKey) {
		this.additionDate = additionDate;
		this.entityId = entityId;
		this.galleryPath = PhotoUtils.getGalleryPath(code);
		this.shootingDate = shootingDate;
		this.titleKey = titleKey;
	}

	/*
	 * Getters & setters.
	 */

	public Integer getEntityId() {
		return entityId;
	}

	public void setEntityId(Integer entityId) {
		this.entityId = entityId;
	}

	public LocalDateTime getAdditionDate() {
		return additionDate;
	}

	public Date getAdditionJdkDate() {
		return additionDate.toDate();
	}

	public void setAdditionDate(LocalDateTime additionDate) {
		this.additionDate = additionDate;
	}

	public LocalDateTime getShootingDate() {
		return shootingDate;
	}

	public Date getShootingJdkDate() {
		return shootingDate.toDate();
	}

	public void setShootingDate(LocalDateTime shootingDate) {
		this.shootingDate = shootingDate;
	}

	public String getGalleryPath() {
		return galleryPath;
	}

	public void setGalleryPath(String galleryPath) {
		this.galleryPath = galleryPath;
	}

	public String getTitleKey() {
		return titleKey;
	}

	public void setTitleKey(String titleKey) {
		this.titleKey = titleKey;
	}

	@Override
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}

}
